package com.mtao.mapper;

import com.mtao.entity.SysRole;
import com.mtao.entity.SysRoleUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysRoleUserMapper {
    /**
     *  通过id获取关联表角色id
     * @param userId
     * @return
     */
    @Select("select id,user_id,role_id from sys_role_user where user_id= #{userId};")
    SysRoleUser getRoleId(Integer userId);

    @Select("select sys_role.id,sys_role.role_code,sys_role.role_name,sys_role_user.user_id " +
            "from sys_role Join sys_role_user on sys_role.id=sys_role_user.role_id " +
            "where user_id= #{userId};")
    List<SysRole> getRoleByUser(Integer userId);
}
